let ObjProto = Object.prototype;
let toString = ObjProto.toString;

let Util = {};

['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet'].forEach(name=> {
    Util['is' + name] = (obj)=> {
        return toString.call(obj) === '[object ' + name + ']';
    };
});

export default Object.assign(Util, {
    isArray(arr) {
        return Array.isArray(arr);
    },
    isEmpty(obj) {
        // filter null, undefined
        if (obj == null) {
            return true;
        }
        if (this.isArray(obj) || Util.isString(obj) || Util.isArguments(obj)) {
            return obj.length === 0;
        }
        return Object.keys(obj).length === 0;
    }
});
